
package com.zpz.framework.zpzoauth.service;

import com.zpz.framework.zpzoauth.pojo.vo.GetAccessByRoleVo;
import org.springframework.security.core.Authentication;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author zhangpanzhi
 * @time 2019-07-09
 * @description 未经本人允许请勿随便改动，尊重劳动
 * */
public interface ZpzOauthPermissionService {
    /**
     * 判断请求是否有权限
     *
	 *	网关对授权token(authentication)的认证校验流程
	 *	1.OAuth2AuthenticationProcessingFilter.doFilter()，执行该过滤器
	 *		Authentication authentication = tokenExtractor.extract(request);获取请求授权信息PreAuthenticatedAuthenticationToken
	 *		Authentication authResult = authenticationManager.authenticate(authentication);如果token不为空，获取授权用户信息
	 *	2.OAuth2AuthenticationManager.authenticate(),获取授权用户信息
	 *		OAuth2Authentication auth = tokenServices.loadAuthentication(token);
	 *	3.DefaultTokenServices.loadAuthentication()，从token存储服务获取用户信息
	 *		OAuth2AccessToken accessToken = tokenStore.readAccessToken(accessTokenValue);
	 *	4.a.从内存获取
	 *	  b.从数据库获取
	 *	  c.从jwt中解析（目前采用）
	 *	  d.从redis中读取
	 *	5.根据授权用户信息，业务自行处理和控制请求
     *
     * @param request        HttpServletRequest
     * @param authentication 认证信息
     * @return 是否有权限 GetAccessByRoleVo
     */
    boolean hasPermission(HttpServletRequest request, Authentication authentication) throws Exception;
	List<GetAccessByRoleVo> getAccessByRoleVos(String clientId, List<String> codes, String ucode)throws Exception;
	List<GetAccessByRoleVo> getAccessByClient()throws Exception;
}
